<template>
  <el-container>
    <el-aside
      width="200px"
    >
      <el-menu unique-opened>
        <!-- 一级菜单 -->
        <el-submenu  :index="item.id+ ''" v-for="item in teacherList" :key="item.id">
          <template slot="title" >
            <i class="el-icon-message"></i>{{item.authName}}</template>
          <!-- 二级菜单 -->
          <el-menu-item @click="jump(subitem.id)" :index="subitem.id+ ''" v-for="subitem in item.children" :key="subitem.id">{{subitem.authName}}</el-menu-item>
        </el-submenu>
      </el-menu>
    </el-aside>
  </el-container>
</template>
<script>
export default {
  data() {
    return {
        teacherList:[]
    };
    
  },
  created() {
        this.getAside()
    },
    methods: {
        getAside(){
            this.$http.get('http://localhost:8080/json/aside.json').then(res =>{
                //console.log(res.data);
                this.teacherList=res.data.data
                //console.log(this.teacherList);
            }, ()=>{
                console.log('数据加载失败')
            })
        },
        jump(index){
          //console.log("aaa");
         // console.log(index);
          if (index===102) {
            this.$router.push("/main")
          }
          if (index===103) {
            this.$router.push("/clazz")
          }
          if (index===104) {
            this.$router.push("/course")
          }
          if (index===105) {
            this.$router.push("/user")
          }
           if (index===106) {
            this.$router.push("/term")
          }
          //this.$router.push("/timetable")
        }
    }
};
</script>
<style lang="scss" scoped>
</style>